<template>
	<!-- 添加或修改追责记录对话框 -->
	<el-dialog :title="dialogTitle" :visible.sync="visible" width="560px" append-to-body>
		<el-form ref="form" :model="formData" :rules="formRules" label-width="80px">
			<el-form-item label="保密人员" prop="userId">
				<person-select v-model="formData.userId" :list="checkedUsers" :disabled="isDisabled"></person-select>
			</el-form-item>
			<el-form-item label="追责日期" prop="punishmentDate">
				<el-date-picker v-bind="dateConfig" v-model="formData.punishmentDate"></el-date-picker>
			</el-form-item>
			<el-form-item label="追责说明" prop="des">
				<el-input v-model="formData.des" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" placeholder="请输入追责说明"></el-input>
			</el-form-item>
		</el-form>
		<template slot="footer">
			<el-button type="primary" @click="handleSubmitData()">确定</el-button>
			<el-button @click="visible = false">取消</el-button>
		</template>
	</el-dialog>
</template>

<script>
import formMixins from '../common/formMixins';
import { getPunishment, addPunishment, updatePunishment } from '@/api/personnal/punishment';
export default {
	mixins: [formMixins],
	data() {
		return {
			formName: '追责记录',
			formRules: {
				userId: { required: true, message: '请选择保密人员', trigger: 'change' },
				punishmentDate: { required: true, message: '请选择追责日期', trigger: 'change' },
				des: { required: true, message: '请输入追责说明', trigger: 'blur' }
			},
			dateConfig: {
				type: 'date',
				editable: false,
				style: { width: '100%' },
				valueFormat: 'yyyy-MM-dd',
				placeholder: '请选择追责日期'
			}
		};
	},
	computed: {
		detailFunction() {
			return eval(getPunishment);
		},
		callFunction() {
			return eval(this.addOrEdit ? addPunishment : updatePunishment);
		}
	},
	watch: {
		userDetail(data) {
			this.$set(this.formData, 'userName', data.name);
		}
	},
	methods: {
		//格式化请求参数
		formatRequestParams() {
			let params = { ...this.formData };
			return params;
		}
	}
};
</script>

<style scoped></style>
